<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>

			<%@ include file="/include/gnb.jsp"%>
			<!-- Main Start -->
			<div id="maincontainer">
				<!-- LeftMenu Start -->
				<div id="leftmenu">
					<%@ include file="/include/lnb.jsp"%>
				</div>
				<!-- Contants Start -->
				<div id="contants">
					<div class="height_10p"></div>
					<form id="commonForm" name="commonForm" method="post">
						<input type="hidden" id="_groupId" name="_groupId" value="${_groupId}" />
						<input type="hidden" id="_menuId" name="_menuId" value="${_menuId}" />
						<input type="hidden" id="_menuNm" name="_menuNm" value="${_menuNm}" />
						<input type="hidden" id="_menuAuth" name="_menuAuth" value="${_menuAuth}" />
						<input type="hidden" id="_prevUpCode" name="_prevUpCode" value="${_prevUpCode}" />
						<input type="hidden" id="_prevCode" name="_prevCode" value="${_prevCode}" />
						<input type="hidden" id="_startRowNo" name="_startRowNo" value="${_startRowNo}" />
						<input type="hidden" id="_pageSize" name="_pageSize" value="12" />
					</form>
					<div id="ajaxDivList" class="noborder"></div>
				</div>
				<!-- Contants End -->
			</div>
		</div>
		<!-- Footer Start -->
		<div id="footer">
			<%@ include file="/include/footer.jsp"%>
		</div>
	</div>

<script>
var url = "portalUserMgmt.action";
var params = "target=umList";
var targetElement = "ajaxDivList";

var pmModule = {
		loadList: function() {
			var rParams = params + "&" + $("#commonForm").serialize() + ($("#loadCheck").val() == "OK" ? ($("#isNew").val() == "Y" ? "&searchVal1=" + $("#searchVal1").val() : "&" + $("#searchForm").serialize()) : "");

			this.makeList(url, rParams);
		},
		
		setBinding: function() {
			var that = this;
			
			$("#searchVal1").keypress(function(e) {
				if (e.keyCode == "13") {
					return false;
				}
			});
			
			$("#searchBtn").bind({
				click: function(e) {
					that.loadList();
				}
			});
		},
		
		setUnbinding: function() {
			$("#searchVal1").unbind();
			$("#searchBtn").unbind();
		},

		setAdd: function() {
			$("#_prevCode").val("");
			
			var rParams = "target=umAdd&" + $("#commonForm").serialize() + "&" + $("#searchForm").serialize();
			
			this.makeList(url, rParams);
		},

		getDetail: function(userId, delYn) {
			if (delYn == "Y") {
				return;
			}
			$("#_prevCode").val(userId);
			
			var rParams = "target=umDetail&" + $("#commonForm").serialize() + ($("#loadCheck").val() == "OK" ? "&" + $("#searchForm").serialize() : "");

			this.makeList(url, rParams);
		},

		setDelete: function() {
			if (!confirm("해당 사용자를 삭제합니다. 계속 하시겠습니까?")) {
				return;
			}
			
			var rParams = "target=umDelete&" + $("#commonForm").serialize() + "&" + $("#searchForm").serialize();
			
			this.makeList(url, rParams);
		},

		setModify: function() {
			$("#searchForm").find("input[type=text]").removeAttr("disabled");
			$("#searchForm").find("input[type=password]").removeAttr("disabled");
			$("#searchForm").find("input[type=radio]").removeAttr("disabled");
			$("#searchForm").find("input[type=file]").show();
			$("#searchForm").find("select").removeAttr("disabled");
			$("#searchForm").find("textarea").removeAttr("disabled");
			$(".btnModify").hide();
			$(".btnSave").show();
		},
		
		save: function() {
			var userId = $("#userId");
			if (userId.val() == "") {
				alert("사용자 ID를 입력하여 주십시오.");
				userId.focus();
				return;
			}

			var userNm = $("#userNm");
			if (userNm.val() == "") {
				alert("사용자 이름을 입력하여 주십시오.");
				userNm.focus();
				return;
			}

			var userPassword = $("#userPassword");
			if (userPassword.val() == "") {
				alert("사용자 비밀번호를 입력하여 주십시오.");
				userPassword.focus();
				return;
			}

			var userAuth = $("input[name=userAuth]:checked").val();
			if (userAuth == "undefined") {
				alert("권한을 선택하여 주십시오.");
				return;
			}
			
			if (!confirm("해당 설정을 저장합니다. 계속 하시겠습니까?")) {
				return;
			}
			
			var rParams = "target=umSave&" + $("#commonForm").serialize() + "&" + $("#searchForm").serialize();

			this.makeList(url, rParams);
		},
		
		restore: function(userId) {
			if (!confirm("사용자 [ " + userId + " ] 의 정보를 복원합니다. 계속 하시겠습니까?")) {
				return;
			}
			
			var rParams = "target=umRestore&userId=" + userId + "&delYn=N&" + $("#commonForm").serialize() + "&" + $("#searchForm").serialize();

			this.makeList(url, rParams);
		},

		reset: function(cmd) {
			$("#searchForm").each(function(){
				this.reset();
			});

			if (cmd == "reset") {
				$("#searchForm").find("input[type=text]").attr("disabled","disabled");
				$("#searchForm").find("input[type=password]").attr("disabled","disabled");
				$("#searchForm").find("input[type=radio]").attr("disabled","disabled");
				$("#searchForm").find("input[type=file]").hide();
				$("#searchForm").find("select").attr("disabled","disabled");
				$("#searchForm").find("textarea").attr("disabled","disabled");
				$(".btnModify").show();
				$(".btnSave").hide();
			}
		},

		getList: function(cmd) {
			if (cmd == "reset") {
				this.reset(cmd);
			}
			this.loadList();
		},
		   
		makeList: function(sUrl, sParams) {
			var that = this;
			
			$.ajax({
				url : sUrl,
				type : "POST",
				data : sParams,
				dataType : "html",
				success : function(data){
					$("#" + targetElement).html(data);

					that.setUnbinding();
					that.setBinding();
					that.initPage();
					sortTable();
					
					if ($("#nodata").html() != null) {
						if ($("#_startRowNo").val() != "0") {
							$("#_startRowNo").val("0");
							loadList();
						} else {
							$("#nodata").css({"height":(parseInt($("#formlist1").css("height").replace("px","")) - 10)});
						}
					}
				}
			});
		},
		
		initPage: function(){
			this.initPageSize();
		},
		     
		initPageSize: function(){
			var msg = "";
			
			// warp
			var valueGwpw = getObjectValue("#warp", "width"); 
			var gwpw = (valueGwpw == null) ? 0 : valueGwpw; // 대상 전체 폭
			var valueGwph = getObjectValue("#warp", "height"); 
			var gwph = (valueGwph == null) ? 0 : valueGwph; // 대상 전체 높이
			msg = appendMessage(msg, "#warp");
			
			setObjectValue("#container", "width", Math.round(gwpw - 40));
			
			// container
			var valueGcw = getObjectValue("#container", "width"); 
			var gcw = (valueGcw == null) ? 0 : valueGcw; // 대상 전체 폭
			var valueGch = getObjectValue("#container", "height"); 
			var gch = (valueGch == null) ? 0 : valueGch; // 대상 전체 높이
			msg = appendMessage(msg, "#container");
			
			// contants
			setObjectValue("#contants", "width", Math.round(gcw - 180 - 10));
			msg = appendMessage(msg, "#contants");
			
			// formtitle
			var valueGftw = getObjectValue("#formtitle", "width");
			var gftw = (valueGftw == null) ? 0 : valueGftw; // 대상 전체 폭
			var valueGfth = getObjectValue("#formtitle", "height"); 
			var gfth = (valueGfth == null) ? 0 : valueGfth; // 대상 전체 높이
			
			// formlist
			var valueGccw = getObjectValue("#contants", "width"); 
			var gccw = (valueGccw == null) ? 0 : valueGccw; // 대상 전체 폭
			var valueGcch = getObjectValue("#contants", "height"); 
			var gcch = (valueGcch == null) ? 0 : valueGcch; // 대상 전체 높이
			
			setObjectValue("#formlist1", "width", Math.round(gccw));
			setObjectValue("#formlist1", "height", Math.round(gcch - gfth - 60));
			msg = appendMessage(msg, "#formlist1");
			
			$(".LoggingMessage").html(msg);     
		}
};

$(document).ready(function(){
	pmModule.loadList();
	pmModule.initPage();
});

$(window).resize(function(){
	pmModule.initPage();
});
</script>
</body>
</html>
